# eric7.Graphics.UMLGraphicsView

Module implementing a subclass of EricGraphicsView for our diagrams.

### Global Attributes

None

### Classes

UMLGraphicsView | Class implementing a specialized EricGraphicsView for our diagrams.

### Functions

None

## UMLGraphicsView

Class implementing a specialized EricGraphicsView for our diagrams.

### Signals

relayout()
  emitted to indicate a relayout of the diagram is requested

### Derived from

EricGraphicsView

### Class Attributes

None

### Class Methods

None

### Methods

UMLGraphicsView | Constructor
__alignShapes | Private slot to align the selected shapes.
__checkSizeActions | Private slot to set the enabled state of the size actions.
__decHeight | Private method to handle the decrease height context menu entry.
__decWidth | Private method to handle the decrease width context menu entry.
__deleteShape | Private method to delete the selected shapes from the display.
__incHeight | Private method to handle the increase height context menu entry.
__incWidth | Private method to handle the increase width context menu entry.
__initActions | Private method to initialize the view actions.
__itemsBoundingRect | Private method to calculate the bounding rectangle of the given items.
__printPreviewPrint | Private slot to generate a print preview.
__relayout | Private slot to handle the re-layout context menu entry.
__rescan | Private slot to handle the re-scan context menu entry.
__sceneChanged | Private slot called when the scene changes.
__setSize | Private method to handle the set size context menu entry.
autoAdjustSceneSize | Public method to adjust the scene size to the diagram size.
event | Public method handling events.
filteredItems | Public method to filter a list of items.
findItem | Public method to find an UML item based on the ID.
findItemByName | Public method to find an UML item based on its name.
fromDict | Public method to populate the class with data persisted by 'toDict()'.
gestureEvent | Protected method handling gesture events.
getItemId | Public method to get the ID to be assigned to an item.
initToolBar | Public method to populate a toolbar with our actions.
keyPressEvent | Protected method handling key press events.
parsePersistenceData | Public method to parse persisted data.
printDiagram | Public slot called to print the diagram.
printPreviewDiagram | Public slot called to show a print preview of the diagram.
saveImage | Public method to handle the save context menu entry.
selectItem | Public method to select an item.
selectItems | Public method to select the given items.
setDiagramName | Public slot to set the diagram name.
setLayoutActionsEnabled | Public method to enable or disable the layout related actions.
toDict | Public method to collect data to be persisted.
wheelEvent | Protected method to handle wheel events.

### Static Methods

None

#### UMLGraphicsView (Constructor)

UMLGraphicsView(scene, parent=None)

Constructor

scene (QGraphicsScene)
  reference to the scene object
parent (QWidget)
  parent widget of the view

#### UMLGraphicsView.__alignShapes

__alignShapes(alignment)

Private slot to align the selected shapes.

alignment (Qt.AlignmentFlag)
  alignment type

#### UMLGraphicsView.__checkSizeActions

__checkSizeActions()

Private slot to set the enabled state of the size actions.

#### UMLGraphicsView.__decHeight

__decHeight()

Private method to handle the decrease height context menu entry.

#### UMLGraphicsView.__decWidth

__decWidth()

Private method to handle the decrease width context menu entry.

#### UMLGraphicsView.__deleteShape

__deleteShape()

Private method to delete the selected shapes from the display.

#### UMLGraphicsView.__incHeight

__incHeight()

Private method to handle the increase height context menu entry.

#### UMLGraphicsView.__incWidth

__incWidth()

Private method to handle the increase width context menu entry.

#### UMLGraphicsView.__initActions

__initActions()

Private method to initialize the view actions.

#### UMLGraphicsView.__itemsBoundingRect

__itemsBoundingRect(items)

Private method to calculate the bounding rectangle of the given items.

items (list of UMLItem)
  list of items to operate on

Return:
  bounding rectangle

Return Type:
  QRectF

#### UMLGraphicsView.__printPreviewPrint

__printPreviewPrint(printer)

Private slot to generate a print preview.

printer (QPrinter)
  reference to the printer object

#### UMLGraphicsView.__relayout

__relayout()

Private slot to handle the re-layout context menu entry.

#### UMLGraphicsView.__rescan

__rescan()

Private slot to handle the re-scan context menu entry.

#### UMLGraphicsView.__sceneChanged

__sceneChanged(_areas)

Private slot called when the scene changes.

_areas (list of QRectF)
  list of rectangles that contain changes (unused)

#### UMLGraphicsView.__setSize

__setSize()

Private method to handle the set size context menu entry.

#### UMLGraphicsView.autoAdjustSceneSize

autoAdjustSceneSize(limit=False)

Public method to adjust the scene size to the diagram size.

limit (bool)
  flag indicating to limit the scene to the initial size

#### UMLGraphicsView.event

event(evt)

Public method handling events.

evt (QEvent)
  reference to the event

Return:
  flag indicating, if the event was handled

Return Type:
  bool

#### UMLGraphicsView.filteredItems

filteredItems(items, itemType=UMLItem)

Public method to filter a list of items.

items (QGraphicsItem)
  list of items as returned by the scene object
itemType (class)
  type to be filtered

Return:
  list of interesting collision items

Return Type:
  QGraphicsItem

#### UMLGraphicsView.findItem

findItem(itemId)

Public method to find an UML item based on the ID.

itemId (int)
  of the item to search for

Return:
  item found or None

Return Type:
  UMLItem

#### UMLGraphicsView.findItemByName

findItemByName(name)

Public method to find an UML item based on its name.

name (str)
  name to look for

Return:
  item found or None

Return Type:
  UMLItem

#### UMLGraphicsView.fromDict

fromDict(_version, data)

Public method to populate the class with data persisted by 'toDict()'.

_version (str)
  version of the data (unused)
data (dict)
  dictionary containing the persisted data

Return:
  flag indicating success

Return Type:
  bool

#### UMLGraphicsView.gestureEvent

gestureEvent(evt)

Protected method handling gesture events.

evt (QGestureEvent)
  reference to the gesture event

#### UMLGraphicsView.getItemId

getItemId()

Public method to get the ID to be assigned to an item.

Return:
  item ID

Return Type:
  int

#### UMLGraphicsView.initToolBar

initToolBar()

Public method to populate a toolbar with our actions.

Return:
  the populated toolBar

Return Type:
  QToolBar

#### UMLGraphicsView.keyPressEvent

keyPressEvent(evt)

Protected method handling key press events.

evt (QKeyEvent)
  reference to the key event

#### UMLGraphicsView.parsePersistenceData

parsePersistenceData(version, data)

Public method to parse persisted data.

version (str)
  version of the data
data (list of str)
  persisted data to be parsed

Return:
  tuple of flag indicating success (boolean) and faulty line number

Return Type:
  int

#### UMLGraphicsView.printDiagram

printDiagram()

Public slot called to print the diagram.

#### UMLGraphicsView.printPreviewDiagram

printPreviewDiagram()

Public slot called to show a print preview of the diagram.

#### UMLGraphicsView.saveImage

saveImage()

Public method to handle the save context menu entry.

#### UMLGraphicsView.selectItem

selectItem(item)

Public method to select an item.

item (QGraphicsItemItem)
  item to be selected

#### UMLGraphicsView.selectItems

selectItems(items)

Public method to select the given items.

items (list of QGraphicsItemItem)
  list of items to be selected

#### UMLGraphicsView.setDiagramName

setDiagramName(name)

Public slot to set the diagram name.

name (str)
  diagram name

#### UMLGraphicsView.setLayoutActionsEnabled

setLayoutActionsEnabled(enable)

Public method to enable or disable the layout related actions.

enable (bool)
  flag indicating the desired enable state

#### UMLGraphicsView.toDict

toDict()

Public method to collect data to be persisted.

Return:
  dictionary containing data to be persisted

Return Type:
  dict

#### UMLGraphicsView.wheelEvent

wheelEvent(evt)

Protected method to handle wheel events.

evt (QWheelEvent)
  reference to the wheel event

Up